package com.kantboot.api.lbs.web.controller;

import com.kantboot.api.lbs.domain.entity.ApiLbsArea;
import com.kantboot.api.lbs.service.IApiLbsAreaService;
import com.kantboot.util.common.result.RestResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api-lbs-web/area")
public class ApiLbsAreaController {

    @Resource
    private IApiLbsAreaService service;

    /**
     * 根据adcode获取区域信息
     */
    @RequestMapping("/getByAdcode")
    public RestResult<ApiLbsArea> getByAdcode(@RequestParam(value = "adcode") String adcode) {
        return RestResult.success(service.getByAdcode(adcode), "getSuccess","获取成功");
    }

    /**
     * 获取所有区域信息
     */
    @RequestMapping("/getAll")
    public RestResult<List<ApiLbsArea>> getAll() {
        return RestResult.success(service.getAll(), "getSuccess","获取成功");
    }

    /**
     * 根据ip获取区域信息
     */
    @RequestMapping("/getByIp")
    public RestResult<ApiLbsArea> getByIp(@RequestParam(value = "ip") String ip) {
        return RestResult.success(service.getByIp(ip), "getSuccess","获取成功");
    }

    /**
     * 根据自身ip获取区域信息
     */
    @RequestMapping("/getBySelfIp")
    public RestResult<ApiLbsArea> getBySelfIp() {
        return RestResult.success(service.getBySelfIp(), "getSuccess","获取成功");
    }

    /**
     * 根据经纬度获取区域信息
     */
    @RequestMapping("/getByLngAndLat")
    public RestResult<ApiLbsArea> getByLngAndLat(@RequestParam(value = "lng") String lng, @RequestParam(value = "lat") String lat) {
        return RestResult.success(service.getByLngAndLat(lng, lat), "getSuccess","获取成功");
    }


}
